# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Marti Raudsepp <marti@juffo.org>
# Contributor: Radu Andries <admiral0@tuxfamily.org>
# Contributor: Andy Weidenbaum <archbaum@gmail.com>

pkgname=zbar
pkgver=0.23.90
pkgrel=2
pkgdesc="Application and library for reading bar codes from various sources"
arch=('x86_64')
url="https://github.com/mchehab/zbar"
license=('LGPL')
depends=('dbus' 'imagemagick' 'libsm' 'libxv' 'v4l-utils')
makedepends=('gtk3' 'qt5-x11extras' 'python' 'xmlto' 'docbook-xsl' 'gobject-introspection')
optdepends=('gtk3: for zbar-gtk'
            'qt5-x11extras: for zbar-qt'
            'python: for zbar python bindings')
conflicts=('zbar-gtk' 'zbar-qt' 'python-zbar')
provides=('zbar-gtk' 'zbar-qt' 'python-zbar')
replaces=('zbar-gtk' 'zbar-qt' 'python-zbar')
source=(
  "$pkgname-$pkgver.tar.gz::https://github.com/mchehab/zbar/archive/refs/tags/$pkgver.tar.gz"
  $pkgname-0.23.90-python3.11.patch  # backport of https://github.com/mchehab/zbar/pull/231
)
sha512sums=('d73d71873bec68ee021997512a9edbd223f5f5fe43c66c4dd3502224ba6009be2e5e1714766cb8e1056244673e87e0939ed0319116f61d7371b5ab79fb5e04eb'
            '4f8518fd93fe5209c2e615801f158cdd64cffaf232c38b3ef2883dc29f9938a72485133e44ab048fddf9f4ffa4da55fe13bdc64829a2f4ffa6cfde8c5fb348ad')
b2sums=('5d0c193509602dfb55741b421e1d28f1424ecec50aa3be584912544a587922c053284c41cf14ff0b4824095d0d376381ed055e7faf9ff394bd8d44fd9ed2971d'
        '8a6a0c788db8bc3eba7a6787dd786ee8b9de14b95f1fd57a43a8eb9a0ab15f8495a31a57d4476373503ccb55c5148baa308bc4f8e9bd6edf07f6f572202b3b3b')

prepare() {
  patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-0.23.90-python3.11.patch
  cd zbar-$pkgver
  autoreconf -vfi
}

build() {
  cd zbar-$pkgver
  ./configure --prefix=/usr --with-qt --with-gtk=gtk3 --with-dbusconfdir=/usr/share CFLAGS="$CFLAGS -DNDEBUG"
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd zbar-$pkgver
  make DESTDIR="$pkgdir" install
}

# vim:set ts=2 sw=2 et:
